/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.googlecode.mailnet.emf.netmodel.impl;

import com.googlecode.mailnet.emf.netmodel.DistributionModel;
import com.googlecode.mailnet.emf.netmodel.NetmodelPackage;
import com.googlecode.mailnet.emf.netmodel.NodeModel;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Node Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.NodeModelImpl#getFailureProbability <em>Failure Probability</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.NodeModelImpl#getFailureDurationDistribution <em>Failure Duration Distribution</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.NodeModelImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class NodeModelImpl extends EObjectImpl implements NodeModel {
	/**
	 * The default value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureProbability()
	 * @generated
	 * @ordered
	 */
	protected static final double FAILURE_PROBABILITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureProbability()
	 * @generated
	 * @ordered
	 */
	protected double failureProbability = FAILURE_PROBABILITY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFailureDurationDistribution() <em>Failure Duration Distribution</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureDurationDistribution()
	 * @generated
	 * @ordered
	 */
	protected DistributionModel failureDurationDistribution;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected NodeModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return NetmodelPackage.Literals.NODE_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getFailureProbability() {
		return failureProbability;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFailureProbability(double newFailureProbability) {
		double oldFailureProbability = failureProbability;
		failureProbability = newFailureProbability;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.NODE_MODEL__FAILURE_PROBABILITY, oldFailureProbability, failureProbability));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel getFailureDurationDistribution() {
		if (failureDurationDistribution != null && failureDurationDistribution.eIsProxy()) {
			InternalEObject oldFailureDurationDistribution = (InternalEObject)failureDurationDistribution;
			failureDurationDistribution = (DistributionModel)eResolveProxy(oldFailureDurationDistribution);
			if (failureDurationDistribution != oldFailureDurationDistribution) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION, oldFailureDurationDistribution, failureDurationDistribution));
			}
		}
		return failureDurationDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel basicGetFailureDurationDistribution() {
		return failureDurationDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFailureDurationDistribution(DistributionModel newFailureDurationDistribution) {
		DistributionModel oldFailureDurationDistribution = failureDurationDistribution;
		failureDurationDistribution = newFailureDurationDistribution;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION, oldFailureDurationDistribution, failureDurationDistribution));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.NODE_MODEL__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case NetmodelPackage.NODE_MODEL__FAILURE_PROBABILITY:
				return new Double(getFailureProbability());
			case NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION:
				if (resolve) return getFailureDurationDistribution();
				return basicGetFailureDurationDistribution();
			case NetmodelPackage.NODE_MODEL__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case NetmodelPackage.NODE_MODEL__FAILURE_PROBABILITY:
				setFailureProbability(((Double)newValue).doubleValue());
				return;
			case NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION:
				setFailureDurationDistribution((DistributionModel)newValue);
				return;
			case NetmodelPackage.NODE_MODEL__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case NetmodelPackage.NODE_MODEL__FAILURE_PROBABILITY:
				setFailureProbability(FAILURE_PROBABILITY_EDEFAULT);
				return;
			case NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION:
				setFailureDurationDistribution((DistributionModel)null);
				return;
			case NetmodelPackage.NODE_MODEL__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case NetmodelPackage.NODE_MODEL__FAILURE_PROBABILITY:
				return failureProbability != FAILURE_PROBABILITY_EDEFAULT;
			case NetmodelPackage.NODE_MODEL__FAILURE_DURATION_DISTRIBUTION:
				return failureDurationDistribution != null;
			case NetmodelPackage.NODE_MODEL__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (failureProbability: ");
		result.append(failureProbability);
		result.append(", name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //NodeModelImpl
